<template>
	<view class="content">
		<view class="buts">
			<ms-dropdown-menu>
			    <ms-dropdown-item v-model="value1" :list="typeList0" class="item"></ms-dropdown-item>
			    <ms-dropdown-item v-model="value2" :list="typeList1" class="item"></ms-dropdown-item>
				<view class="GBP">
					<text class="GBP_text">国标价{{GBPrice}}</text> 
				</view>
			</ms-dropdown-menu>
		</view>

		<view class="info">
			<view class="info_item" v-for="(item,index) in data" @click="chengeList(item)" :key="index">
				<view class="item_image">
					<image class="image_0" src="../../static/you.png" mode="aspectFill"></image>
				</view>
				<view class="info_top" style="display: flex;">
					<view class="info_title">
						<text class="title_name">{{item.station}}</text>
						<text class="title_address">{{item.addr}}</text>
						<view class="title_price" v-for="(items,idx) in item.prices" v-if="idx<1" :key="items.gid">
							<view class="price_0"> 
								<text>￥</text>
								<text>{{items.price}}</text>
							</view>
							<view class="price_1">
								<text v-show="items.yjj>0">已降价{{items.yjj}}元/升</text>
							</view>
						</view>
					</view>
				</view>
				<view class="info_juli">
					<image src="../../static/juli.png" mode="aspectFill" class="juli_image"></image>
					<text class="juli_text">100km</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import msDropdownMenu from '@/components/ms-dropdown/dropdown-menu.vue'
	import msDropdownItem from '@/components/ms-dropdown/dropdown-item.vue'
	export default {
		components: {
		    msDropdownMenu,
            msDropdownItem
        },
		created() {
			this.$myRequest({
				url:"user/get_gas_station",
				data:{
					sort:"0",
					page:"1",
					page_size:"10",
					city:"石家庄",
					lat:"38.048479499922962",
					lng:"114.48525944706392",
				},
			}).then(res => {
				this.data = res.return.list;
				console.log(this.data)
				this.data.forEach(item => {
					item.prices.forEach(items => {
						items['yjj'] = ((Number(items.gtprice) - Number(items.price))).toFixed(2);
					})
					lat:"38.048479499922962"
					lng:"114.48525944706392"
					item['juli'] =this.GetDistance(lat, lng, items.lat, items.lng);
				})
								
			}).catch(err => {
			    //请求失败
			    console.log("失败"+err)
			})
		},
		data() {
			return {
				data:"",
				typeList0: [
					{
					    name:'汽油',
					    list:[
				            {
			    	            text: '#92',
				                value: 0
	    			        },
		    		        {
			    	            text: '#95',
				                value: 1
	    			        },
		    		        {
			    	            text: '#98',
			    	            value: 2
				            },
							,
							{
							    text: '#00',
							    value: 2
							}
				        ]
			    	},
				],
				typeList1: [
					{
						name:'排序',
						list:[
					    {
					        text: '智能排序',
					        value: '智能排序'
					    },
					    {
					        text: '距离排序',
					        value: '距离排序'
					    },
					    {
					        text: '价格排序',
					        value: '价格排序'
					    }
					]
					},
				],
				value1: 0,
				value2: 0,
				GBPrice:'￥5.59'
			}
		},

		methods: {
			chengeList(item){
				let isLogin = uni.getStorageSync("isLogin");
				if (isLogin) {
					uni.navigateTo({
						url:'../stationDetails/stationDetails?item='+JSON.stringify(item),
					})
				}else{
					
				}
				
			}
		}
	}
</script>

<style lang="scss">
	.content {
		.info{
			padding-top: 80rpx;
			.info_item{
				width: 710rpx;
				margin: 20rpx auto;
				background-color: #FFFFFF;
				border-radius: 15rpx;
				display: flex;
				.item_image{
					width: 100rpx;
					.image_0{
						margin-top: 40rpx;
						margin-left: 15rpx;
						width: 70rpx;
						height: 70rpx;
					}
				}
				.info_top{
					.info_title{
						margin-left: 20rpx;
						margin-top: 27rpx;
						width: 430rpx;
						.title_name{
							color: #333333;
							font-size: 34rpx;
							font-weight: 600;
							overflow:hidden;
							text-overflow:ellipsis;
							display:-webkit-box;
							-webkit-box-orient:vertical; 
							-webkit-line-clamp:2; 
						}
						.title_address{
							font-size: 26rpx;
							margin-top: 10rpx;
							color: #666666;
							font-weight: 400;
							overflow:hidden;
							text-overflow:ellipsis;
							display:-webkit-box;
							-webkit-box-orient:vertical; 
							-webkit-line-clamp:2; 
						}
						.title_price{
							width: 430rpx;
							height: 86rpx;
							line-height: 80rpx;
							
							margin-top: 10rpx;
							display: flex;
							.price_0{
								margin: auto 0;
								height: 50rpx;
								line-height: 50rpx;
								font-size: 26rpx;
								font-weight: 500;
								color: rgba(239, 3, 38, 1);
								text:nth-child(2) {
									font-size: 42rpx;
									
								}
							}
							.price_1{
								width: 240rpx;
								height: 50rpx;
								line-height: 50rpx;
								background: rgba(247, 51, 75, 1);
								border-radius: 8rpx;
								font-size: 26rpx;
								color: #FFFFFF;
								text-align: center;
								margin: auto 42rpx;
								font-weight: 400;
							}
						}
					}
					
				}
				.info_juli{
					width: 170rpx;
					height: 100rpx;
					display: grid;
					margin: 40rpx 5rpx;
					.juli_image{
						width: 30rpx;
						height: 30rpx;
						margin-left: 20rpx;
						margin-top: 35rpx;
					}
					.juli_text{
						width: 120rpx;
						height: 50rpx;
						margin-top: -50rpx;
						margin-left: 50rpx;
						font-weight: 400;
						font-size: 28rpx;
					}
				}
			}
		}
		
		.buts{
			width: 100%;
			height: 80rpx;
			background-color: #FFFFFF;
			position: fixed;
			.item{
				width: 33.333%;
				height: 80rpx;
				line-height: 80rpx;
				font-size: 28rpx;
				margin: 0 0;
			}
			.GBP{
				width: 200rpx;
				height:40rpx;
				background-color: #F2F2F2;
				margin: auto 0;
				border-radius: 5rpx;
				display: grid;
				.GBP_text{
					width: 100%;
					height: 40rpx;
					line-height: 40rpx;
					color: #AAAAAA;
					font-size: 26rpx; 
					text-align: center;
				}
			}
		}
	}
</style>
